package com.example.project.controller;

import com.example.project.entity.User;
import com.example.project.service.IUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 作者：金照富
 * 2023年11月3日
 */
@RestController
@Api
public class UserController {
    @Autowired
    private IUserService userService;

    @ApiOperation(value = "添加用户")
    @RequestMapping("/insertUser")
    public int insertUser1(User user){
        return userService.insertUser1(user);
    }

    @ApiOperation(value = "删除用户")
    @RequestMapping("/deleteUser")
    public int deleteUser1(int id){
        User user=new User();
        user.setUserId(id);
        return userService.deleteUser1(user);
    }

    @ApiOperation(value = "修改用户信息")
    @RequestMapping("/updateUser")
    public int updateUser(User user){
        return userService.updateUser1(user);
    }

    @ApiOperation(value = "查询所有用户信息")
    @RequestMapping("/getAllUser")
    public List<User> getAllUser(User user){
        return userService.getAllUser1(user);
    }

    @ApiOperation(value = "查询用户信息")
    @RequestMapping("/getUser")
    public User getUser(int id){
        User user=new User();
        user.setUserId(id);
        return userService.getUser1(user);
    }
}